﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class adm_vlg_yourPage : System.Web.UI.Page
{
    CommonPage cm3 = new CommonPage();
    VLGDataContext _db8 = new VLGDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (cm3.IsAuthenticated == false)
            {
                Response.Redirect(ResolveClientUrl("~/accessDenied.aspx"));
            }
            else
            {
                fillDulieuLenGrid();
            }
        }
    }

    void fillDulieuLenGrid()
    {
        //int idUs = cm3.Customer.idAcc;
        var gigCate = from gg2 in _db8.Categories                        
                        orderby gg2.ThuTu
                        select gg2;
        //DataList1.DataSource = gigCanhan;
        //DataList1.DataBind();
        GridView1.DataSource = gigCate;
        GridView1.DataBind();
    }
    protected void linkAdd_Click(object sender, EventArgs e)
    {
        Response.Redirect(ResolveClientUrl("~/qlcongviec.aspx?op=add"));
    }
    protected void linkDelG_Click(object sender, EventArgs e)
    {
        try
        {
            string lDel = ((LinkButton)sender).CommandArgument.ToString();
            Gig giDel = _db8.Gigs.Single(iiiid => iiiid.idGig == int.Parse(lDel));
            _db8.Gigs.DeleteOnSubmit(giDel);
            _db8.SubmitChanges();
            this.fillDulieuLenGrid();
        }
        catch {
            this.fillDulieuLenGrid();
            //Literal1.Text = "<script type=\"text/javascript\">" +
            //                    "$(function() { " +
            //                    "alert(\"Không thể xóa công việc này. Vì đang có đơn đặt hàng.\");" +
            //                    "});" +
            //                    "</script>";
        }
    }
    protected void linkEditG_Click(object sender, EventArgs e)
    {

    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {

    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {

    }
}
